import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";

import "@unocss/reset/tailwind.css"; // 选择你喜欢的重置样式
import "virtual:uno.css"; // UnoCSS 的核心样式

import "amfe-flexible";
// 引入 i18n
import i18n from "@/locales/i18n";
// 计算rem
function setRemUnit() {
  // 设计稿宽度（根据你的设计稿调整）
  const designWidth = 1920;
  // 基准大小（1rem = 100px）
  const baseSize = 100;

  // 当前窗口宽度
  const scale = document.documentElement.clientWidth / designWidth;
  // 设置根字体大小
  document.documentElement.style.fontSize =
    baseSize * Math.min(scale, 2) + "px";
}

// 初始化调用
// setRemUnit();
// 窗口大小变化时重新设置
window.addEventListener("resize", setRemUnit);

import { createPinia } from "pinia";
import { directives } from "@/directives/index";
import DataVVue3 from "@kjgl77/datav-vue3";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
import router from "./router";
const app = createApp(App);
console.log(directives)
for (const key in directives) {
  console.log(key, 40);
  app.directive(key, directives[key]);
}

app.use(DataVVue3);

app.use(pinia);
app.use(router);
app.use(i18n);
app.mount("#app");
